/*
 * @Author: szx
 * @Date: 2021-11-23 16:21:26
 * @LastEditTime: 2021-11-23 16:38:54
 * @Description:
 * @FilePath: \leetcode\1-99\45\45.js
 */
/**
 * @param {number[]} nums
 * @return {number}
 */
var jump = function (nums) {
    const n = nums.length;
    let dp = 0;
    let res = 0;
    let end = 0;
    for (let i = 0; i < n - 1; i++) {
        dp = Math.max(dp, nums[i] + i);
        if (i == end) {
            end = dp;
            res++;
        }
    }
    return res;
};
console.log(jump([2,3,1]));
